/*
 * This file is part of shared-drawing.
 * shared-drawing is free software: you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option )
 * any later version. shared-drawing is distributed in the hope that it will
 * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 * You should have received a copy of the GNU General Public License along with 
 * shared-drawing. If not, see http://www.gnu.org/licenses/.
 */

package primitives;
import SharedDrawing.Page;
import SharedDrawing.WgContent;
import java.awt.Color;
import java.awt.Graphics2D;

public abstract class Primitive 
{
	protected long m_elementId; 
	protected String m_type;
	protected Color m_color;
	protected Color m_borderColor;
	protected int m_width;
	protected boolean m_isFilled;
    protected Page m_page;
	
	/**
	 * Function used to initialize the primitive common attributes
	 * @param width: width of the border/component
	 * @param fill: component filled or not
	 * @param color: main color of the primitive
	 * @param border: border color of the primitive
	 */
	protected void initPrimitive(int width, boolean fill, Color color, Color border)
	{
		m_width = width;
		m_isFilled = fill;
		m_color = color;
		m_borderColor = border;
	}
	
	public abstract void initPrimitive(int x, int y, int width, boolean fill, Color color, Color border);
	
	/**
	 * Function used to draw the primitive
	 */
	public abstract void drawComponent(Graphics2D g);
	
	/**
	 * Function used to know if the user click on this element
	 * @param x: mouse x-axis
	 * @param y: mouse y-axis
	 * @return true if the mouse is over the element, false else
	 */
	public abstract boolean isOverObject(int x, int y);
	
	/**
	 * Function used to transform the current element in a wgContent
	 * @return the wgContent with the values depending of the object
	 */
	public abstract WgContent toWgContent();
	
	/**
	 * Function used to set the attributes of the object from a wgContent
	 * @param wg the wgContent used to set the values
	 */
	public abstract void fromWgContent(WgContent wg);
	
	/**
	 * Function used to set the location and size of the primitive
	 * @param x: upper-left corner of the Shape x-axis
	 * @param y: upper-left corner of the Shape y-axis
	 * @param w_x1: down-right corner/size of the Shape x-axis
	 * @param h_y1: down-right corner/size of the Shape x-axis
	 */
	public abstract void setShape(int x, int y, int w_x1, int h_y1);
	
	/**
	 * Function used to eventually get the main graphic component of the primitive
	 * @return the graphic component implemented in the primitive
	 */
	public abstract Object getShape();

	public Color getColor() {
		return m_color;
	}

	public void setColor(Color m_color) {
		this.m_color = m_color;
	}

	public Color getBorderColor() {
		return m_borderColor;
	}

	public void setBorderColor(Color m_borderColor) {
		this.m_borderColor = m_borderColor;
	}
	
	public String getType()
	{
		return m_type;
	}
	
	public int getWidth()
	{
		return m_width;
	}

	public boolean isFilled()
	{
		return m_isFilled;
	}
	
	public long getElementId()
	{
		return m_elementId;
	}
	
	public void setElementId(long id)
	{
		m_elementId = id;
	}
}
